#include "ic_handler.h"

void handler::ic_handler::handle_event(boost::shared_ptr<network::event> n) 
{
	boost::shared_ptr<model::dom> node(n->node);
	if(node->name() == "temp") {
		do_temp(node);
	}
}

void handler::ic_handler::notify(const network::notifier *n)
{
	// we don't store any data here, thus we don't delete here anything...
	boost::shared_ptr<handler::ic_handler> tmp(_this.lock());
	fire_listener();
}

void handler::ic_handler::do_temp(boost::shared_ptr<model::dom> node)
{
	string temp = node->find_attrib("value");
	boost::shared_ptr<network::send_impl> impl(
		network::singletone<network::configurator>::instance()->
			get_web_send_impl());
	boost::shared_ptr<network::temperature> ptr_temp(
		new network::temperature(impl, temp));
	_web->send(ptr_temp->get_string());
}

